class HeroScene extends eui.Component implements eui.UIComponent {
	public list_hero:eui.List;
	public scrollBox:eui.Scroller;
	public return_btn:eui.Button;
	public btnOK:eui.Button;
	public constructor() {
		super();
	}

	protected partAdded(partName: string, instance: any): void {
		super.partAdded(partName, instance);
	}


	protected childrenCreated(): void {
		super.childrenCreated();


		// 原始数组

		let dataArr: any[] = [

			{ image: 'resource/art/heros_goods/heros01.png', name: '亚特伍德', value: '评价: 很特么厉害, 为所欲为', isSelected: false },

			{ image: 'resource/art/heros_goods/heros02.png', name: '亚特伍德', value: '评价: 很特么厉害, 为所欲为', isSelected: false },

			{ image: 'resource/art/heros_goods/heros03.png', name: '亚特伍德', value: '评价: 很特么厉害, 为所欲为', isSelected: true },

			{ image: 'resource/art/heros_goods/heros04.png', name: '亚特伍德', value: '评价: 很特么厉害, 为所欲为', isSelected: false },

			{ image: 'resource/art/heros_goods/heros05.png', name: '亚特伍德', value: '评价: 很特么厉害, 为所欲为', isSelected: false },

			{ image: 'resource/art/heros_goods/heros06.png', name: '亚特伍德', value: '评价: 很特么厉害, 为所欲为', isSelected: false },

			{ image: 'resource/art/heros_goods/heros07.png', name: '亚特伍德', value: '评价: 很特么厉害, 为所欲为', isSelected: false }


		]

		// 转成EUI数组

		let EUIArr: eui.ArrayCollection = new eui.ArrayCollection(dataArr)

		// 把list_hero数据源设置成EUIArr
		this.list_hero.dataProvider = EUIArr;
		// 设置itemRenderer
		this.list_hero.itemRenderer = Herolist_item;
		this.scrollBox.verticalScrollBar.autoVisibility = false;

		// 返回
		this.return_btn.addEventListener(egret.TouchEvent.TOUCH_TAP,(e)=>{
			SceneManager.toMainScene();
		},this)
		// 确认
		this.btnOK.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
			// SceneManager.toMainScene();

			let dataProvider = this.list_hero.dataProvider;
			let arr:string[]=[];

			for(let i=0,len=dataProvider.length;i<len;i++){
				let item = 	dataProvider.getItemAt(i);
				if(item.isSelected){
					arr.push(item.name)
				}
			}
			egret.log(arr);

			let text:string = '你选择了：'
			if(arr.length==0){
				text = '什么都没选~~';
			}else{
				text+= arr.join(',');
			}
			SceneManager.showinfo(this,text);

		},this)
	}

}